// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	10/9/2014 6:31:02 PM				
// -----------------------------

#include "Timer.h"

Timer::Timer()
	: m_Frequency(0)
	, m_StartTime(0)
	, m_LastTime(0)
	, m_ThisTime(0)
{
	Reset();
}

Timer::~Timer()
{
}

void Timer::Reset()
{
	QueryPerformanceFrequency((LARGE_INTEGER*)&m_Frequency);
	QueryPerformanceCounter((LARGE_INTEGER*)&m_StartTime);
	m_LastTime = m_StartTime;
	m_ThisTime = m_StartTime;
}
void Timer::Update()
{
	m_LastTime = m_ThisTime;
	QueryPerformanceCounter((LARGE_INTEGER*)&m_ThisTime);
}

Float Timer::GetElapsedTime() const
{
	Float diff = (Float)m_ThisTime - m_StartTime;
	return (diff / m_Frequency);
}
Float Timer::GetDeltaTime() const
{
	Float diff = (Float) m_ThisTime - m_LastTime;
	return (diff / m_Frequency);
}